unit nncrypt32;

interface

uses
  SysUtils, Classes;

type
  TCipherType = (ctBlowFish, ctCast128, ctCast256, ctDes, ct3Des, ctGost, ctIce, ctThinIce,
                 ctIce2, ctIdea, ctMars, ctMisty1, ctRC2, ctRC4, ctRC5, ctRC6, ctRijndael,
                 ctSerpent, ctTea, ctTwoFish);

  THashType = (htHaval, htMD4, htMD5, htRipemd128, htRipemd160, htSHA1, htSHA256, htSHA384,
               htSHA512, htTiger);

{$IFNDEF WINDOWS}
  {*************************************************************************************}
  {*                                                                                   *}
  {* Result codes:                                                                     *}
  {*   0: Successful executed                                                          *}
  {*  -1: Key String is empty                                                          *}
  {*  -2: String is empty                                                              *}
  {*  -3: Incorrect type of Cipher selected                                            *}
  {*  -4: Incorrect type of Hash selected                                              *}
  {*                                                                                   *}
  {*************************************************************************************}
  function EncryptString(AKeyString, AStr: WideString; ACipher: TCipherType;
    AHash: THashType; var AResult: WideString): Integer; stdcall; external 'nncrypt32.dll';

  {*************************************************************************************}
  {*                                                                                   *}
  {* Result codes:                                                                     *}
  {*   0: Successful executed                                                          *}
  {*  -1: Key String is empty                                                          *}
  {*  -2: String is empty                                                              *}
  {*  -3: Incorrect type of Cipher selected                                            *}
  {*  -4: Incorrect type of Hash selected                                              *}
  {*                                                                                   *}
  {*************************************************************************************}
  function DecryptString(AKeyString, AStr: WideString; ACipher: TCipherType;
    AHash: THashType; var AResult: WideString): Integer; stdcall; external 'nncrypt32.dll';

  {*************************************************************************************}
  {*                                                                                   *}
  {* Result codes:                                                                     *}
  {*   0: Successful executed                                                          *}
  {*  -1: Key String is empty                                                          *}
  {*  -2: Source file does not exist                                                   *}
  {*  -3: Incorrect type of Cipher selected                                            *}
  {*  -4: Incorrect type of Hash selected                                              *}
  {*  -5: Path of source file is empty                                                 *}
  {*  -6: Path of destination file is empty                                            *}
  {*  -7: Cannot open source file                                                      *}
  {*  -8: Cannot create destination file                                               *}
  {*  -9: Could not encrypt the file stream                                            *}
  {*                                                                                   *}
  {*************************************************************************************}
  function EncryptFile(AKeyString, ASource, ADest: WideString; ACipher: TCipherType;
    AHash: THashType): Integer; stdcall; external 'nncrypt32.dll';

  {*************************************************************************************}
  {*                                                                                   *}
  {* Result codes:                                                                     *}
  {*   0: Successful executed                                                          *}
  {*  -1: Key String is empty                                                          *}
  {*  -2: Source file does not exist                                                   *}
  {*  -3: Incorrect type of Cipher selected                                            *}
  {*  -4: Incorrect type of Hash selected                                              *}
  {*  -5: Path of source file is empty                                                 *}
  {*  -6: Path of destination file is empty                                            *}
  {*  -7: Cannot open source file                                                      *}
  {*  -8: Cannot create destination file                                               *}
  {*  -9: Could not decrypt the file stream                                            *}
  {*                                                                                   *}
  {*************************************************************************************}
  function DecryptFile(AKeyString, ASource, ADest: WideString; ACipher: TCipherType;
    AHash: THashType): Integer; stdcall; external 'nncrypt32.dll';

  {*************************************************************************************}
  {*                                                                                   *}
  {* Result codes:                                                                     *}
  {*   0: Successful executed                                                          *}
  {*  -1: String is empty                                                              *}
  {*  -2: Could not calculate the MD5 Checksum for suplied string                      *}
  {*                                                                                   *}
  {*************************************************************************************}
  function MD5String(AStr: WideString; var ACheckSum): Integer; stdcall;
    external 'nncrypt32.dll';

  {*************************************************************************************}
  {*                                                                                   *}
  {* Result codes:                                                                     *}
  {*   0: Successful executed                                                          *}
  {*  -1: Path of source file is empty                                                 *}
  {*  -2: Source file does not exist                                                   *}
  {*  -3: Cannot open source file                                                      *}
  {*  -4: Could not calculate the MD5 Checksum for suplied source file                 *}
  {*                                                                                   *}
  {*************************************************************************************}
  function MD5File(ASource: WideString; var ACheckSum: WideString): Integer; stdcall;
    external 'nncrypt32.dll';
{$ELSE}
{$IFNDEF LINUX}
  function EncryptString(AKeyString, AStr: WideString; ACipher: TCipherType;
    AHash: THashType; var AResult: WideString): Integer; stdcall; external 'nncrypt32.so';

  function DecryptString(AKeyString, AStr: WideString; ACipher: TCipherType;
    AHash: THashType; var AResult: WideString): Integer; stdcall; external 'nncrypt32.so';

  function EncryptFile(AKeyString, ASource, ADest: WideString; ACipher: TCipherType;
    AHash: THashType): Integer; stdcall; external 'nncrypt32.so';

  function DecryptFile(AKeyString, ASource, ADest: WideString; ACipher: TCipherType;
    AHash: THashType): Integer; stdcall; external 'nncrypt32.so';

  function MD5String(AStr: WideString; var ACheckSum): Integer; stdcall;
    external 'nncrypt32.so';

  function MD5File(ASource: WideString; var ACheckSum: WideString): Integer; stdcall;
    external 'nncrypt32.so';
{$ELSE}
{$IFNDEF MACOSX}
  function EncryptString(AKeyString, AStr: WideString; ACipher: TCipherType;
    AHash: THashType; var AResult: WideString): Integer; stdcall; external 'nncrypt32.dylib';

  function DecryptString(AKeyString, AStr: WideString; ACipher: TCipherType;
    AHash: THashType; var AResult: WideString): Integer; stdcall; external 'nncrypt32.dylib';

  function EncryptFile(AKeyString, ASource, ADest: WideString; ACipher: TCipherType;
    AHash: THashType): Integer; stdcall; external 'nncrypt32.dylib';

  function DecryptFile(AKeyString, ASource, ADest: WideString; ACipher: TCipherType;
    AHash: THashType): Integer; stdcall; external 'nncrypt32.dylib';

  function MD5String(AStr: WideString; var ACheckSum): Integer; stdcall;
    external 'nncrypt32.dylib';

  function MD5File(ASource: WideString; var ACheckSum: WideString): Integer; stdcall;
    external 'nncrypt32.dylib';
{$ENDIF}
{$ENDIF}
{$ENDIF}

implementation

end.